export default class extends think.BaseController {
    /**
     * 通过businesskey查询所有案件信息
     * @param {String} businesskey          部件id
     * @returns
     */
    async queryCaseByKeyAction() {
        const aj = think.ajaxJson();
        const getData = {
            businesskey: this.get('businesskey')
        };
        const CaseService = this.service('oa/CaseService');
        const res = await CaseService.getCaseByKey(getData);
        if (!res.error) {
            aj.result = res;
        } else {
            aj.success = false;
            aj.msg = '查询失败';
        }
        return this.json(aj);
    }
    /**
     * 查询案件信息
     *
     * @returns
     */
    async queryCaseAllAction() {
        const aj = think.ajaxJson();
        const CaseService = this.service('oa/CaseService');
        const res = await CaseService.getCaseAll(this.getUser());
        if (!res.error) {
            aj.result = res;
        } else {
            aj.success = false;
            aj.msg = '查询失败';
        }
        return this.json(aj);
    }
    /**
     * 通过porcid查询案件信息
     * @returns
     */
    async queryCaseByProcIdAction() {
        const aj = think.ajaxJson();
        const CaseService = this.service('oa/CaseService');
        const proc_inst_id = this.post('proc_inst_id');
        const res = await CaseService.getCaseByProcId(proc_inst_id);
        if (!res.error) {
            aj.result = res;
        } else {
            aj.success = false;
            aj.msg = '查询失败';
        }
        return this.json(aj);
    }

    /**
     * 部门评价
     */
    async getOrgEvalAction() {
        const aj = think.ajaxJson();
        const CaseService = this.service('oa/CaseService');
        const data = {
            orgList: this.get('orgList')
        };
        const res = await CaseService.getOrgEval(data);
        if (!res.error) {
            aj.result = res;
        } else {
            aj.success = false;
            aj.msg = '查询失败';
        }
        return this.json(aj);
    }

    async getCaseViaAction() {
        const aj = think.ajaxJson();
        const CaseService = this.service('oa/CaseService');
        const data = this.get('page,pageSize,remarks,case_type,time,area_code,DeptCodes,case_code,parent_name');
        const res = await CaseService.getCaseViaAll(data, this.getUser());
        if (!res.error) {
            aj.result = res;
        } else {
            aj.success = false;
            aj.msg = '查询失败';
        }
        return this.json(aj);
    }

    async getPartsCaseAction() {
        const aj = think.ajaxJson();
        const CaseService = this.service('oa/CaseService');
        const data = this.post('page,pageSize,area_code,startTime,endTime');
        const res = await CaseService.getPartsCase(data, this.getUser());
        if (!res.error) {
            aj.result = res;
        } else {
            aj.success = false;
            aj.msg = '查询失败';
        }
        return this.json(aj);
    }
}
